﻿@model Inscriptionem.Areas.Inscriptionem.Models.Views.CategoryCollectionViewModel

@{
    ViewBag.Title = "Inscriptionem » Categories";
    Layout = "../Shared/Layout.cshtml";

    ViewBag.CurrentPage = "Categories";
}

<div class="outer" id="contentwrap">
    @{Html.RenderPartial("NavigationMenu");}
    <div class="postcont">
		<div id="content">
            <div class="post type-post status-publish format-standard hentry">
                <h2 class="title">Categories</h2>
                <div class="postdate-single error-message"></div>

                <table width="100%">
                    <thead>
                        <tr class="postdate">
                            <td>Order</td>
                            <td>Category</td>
                            <td>Section</td>
                            <td>Section Name</td>
                            <td>Language</td>
                            <td>Language Name</td>
                            <td style="width: 60px;"></td>
                            <td style="width: 60px;"></td>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach(var category in Model.Categories.OrderBy(c => c.Section.Language.ID).ThenBy(c => c.Section.ID).ThenBy(c => c.ID))
                    {
                    <text>
                    <tr>
                        <td>@category.Order</td>
                        <td>@category.Name</td>
                        <td>@category.Section.Name</td>
                        <td>@category.Section.LocalizedName</td>
                        <td>@category.Section.Language.Name</td>
                        <td>@category.Section.Language.LocalizedName</td>
                        <td>
                            <form method="post" action="/Inscriptionem/Category/Edit">
                                <input type="hidden" name="ID" value="@category.ID" />
                                <input type="submit" value="Edit" />
                            </form>
                        </td>
                        <td>
                            <form method="post" action="/Inscriptionem/Category/Delete">
                                <input type="hidden" name="ID" value="@category.ID" />
                                <input type="submit" value="Delete" />
                            </form>
                        </td>
                    </tr>
                    </text>
                    }
                    <tr>
                        <td><a href="/Inscriptionem/Category/Order">Change</a></td>
                    </tr>
                    </tbody>
                </table>
                <hr />
                <form method="post" action="/Inscriptionem/Category/Add">
                    <div class="postdate">Add Category</div>
				    <div class="entry">
                        <p>Order <input type="text" name="Order" value="" /></p>
                        <p>Category <input type="text" name="Name" value="" /></p>
                        <p>Section
                            <select name="Section">
                            @foreach (var language in Model.Languages)
                            {
                                if (language.Sections.Any())
                                {
                                <text>
                                <optgroup label="@language.Name / @language.LocalizedName">
                                    @foreach (var section in language.Sections.OrderBy(s => s.Order))
                                    {
                                        <text>
                                        <option value="@(section.ID)">@(section.Name) / @(section.LocalizedName)</option>
                                        </text>
                                    }
                                </optgroup>
                                </text>
                                }
                            }
                            </select>
                        </p>
	                </div>

                    <input type="reset" value="Reset" />&nbsp;|&nbsp;<input type="submit" value="Add" />
                </form>
			</div>
        </div>
	</div>	
</div>
